package cn.qp.exception;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

/**
 * @author qipan
 * @date 2020/01/11 10:45
 */
@ControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler(value = Exception.class)
    @ResponseBody
    public Map<String, Object> handleException(Exception e) {
        final HashMap<String, Object> map = new HashMap<String, Object>();
        map.put("errorCode",500);
        map.put("errorMsg",e.toString());
        return map;
    }
}
